package com.atguigu.gulimall.coupon.controller;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.coupon.entity.CouponEntity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

/**
 * 测试
 * @return
 * @author zzf
 * @date 2020/8/17 17:43
 */
@RefreshScope
@RestController
@RequestMapping("coupon")
public class TestController {

    @Value("${coupon.user.name}")
    private String name;

    @Value("${coupon.user.age}")
    private Integer age;

    /**
     * 测试远程调用,获取所有优惠券
     */
    @RequestMapping("/member/list")
    public R memberlist(){
        CouponEntity couponEntity = new CouponEntity();
        couponEntity.setCouponName("满100减10;");
        return R.ok().put("coupons", Arrays.asList(couponEntity));
    }

    /**
     * 测试配置中心
     */
    @RequestMapping("/test/config")
    public R testConfig(){
        return R.ok().put("name",name).put("age",age);
    }
}
